﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mimoza.Transport;

namespace Mimoza.ServiceLayer
{
    class NotificationInfo
    {
        const string ValueName = "ModifiedFieldName";

        public static void Set(string modifiedFieldName)
        {
            ThreadStore.SetValue(ValueName, modifiedFieldName);
        }

        public static void Reset()
        {
            ThreadStore.ClearValue(ValueName);
        }

        public static string Get()
        {
            if (ThreadStore.IsExists(ValueName))
            {
                return ThreadStore.GetValue(ValueName) as string;
            }
            else return null;
        }

        public static bool IsSet()
        {
            if (!string.IsNullOrEmpty(Get())) return true;
            else return false;
        }
    }


    class NotificationAutoSet : IDisposable
    {
        public NotificationAutoSet(string modifiedFieldName)
        {
            NotificationInfo.Set(modifiedFieldName);
        }
    
#region IDisposable Members

        public void  Dispose()
        {
            NotificationInfo.Reset();
        }

#endregion
}
}
